package com.edfu.core.commons.persistence.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import com.edfu.core.testmgt.persistence.entity.TestEntity;

@Entity
@Table(name="category", uniqueConstraints=@UniqueConstraint(columnNames={"name"}))
public class CategoryEntity {
	private long id;
	private String name;
	private String description;
	private CategoryEntity parentCategory;	
	private Set<TestEntity> tests = new HashSet<TestEntity>();
	
	@ManyToOne
	@JoinColumn(name = "parentCategory_id", nullable = true)
	public CategoryEntity getParentCategory() {
		return parentCategory;
	}
	public void setParentCategory(CategoryEntity parentCategory) {
		this.parentCategory = parentCategory;
	}
	
	@ManyToMany(mappedBy = "categories")
	public Set<TestEntity> getTests() {
		return tests;
	}
	public void setTests(Set<TestEntity> tests) {
		this.tests = tests;
	}
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public long getId() {
		return id;
	}	
	public void setId(long id) {
		this.id = id;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}	
	
}